﻿using System;
using System.Collections.Generic;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using IService.DataDLL.Utility;
using IService.Model;
using IService.Business;

namespace IService
{
	public partial class NewInfo : System.Web.UI.Page
	{
		protected void Page_Load(object sender, EventArgs e)
		{
			if (!base.IsPostBack)
			{
				CheckIntType(NewsID);
			}
		}

		protected void CheckIntType(string param)
		{
			if (!ParamHandler.IsLegalForInt(param))
			{
				Response.Redirect(StringUtil.GetAppConfigString("AdminParamErrorPage"));
			}
		}

		protected Dictionary<string, string> GetNewsContent
		{
			get
			{
				Dictionary<string, string> result = ContentDetail;
				if (result == null)
				{
					result = new Dictionary<string, string>();
					int newsid = int.Parse(NewsID);
					News news = DTVBusiness.NewsManager.GetNewsById(newsid);
					result.Add("NewsTitle", news.NewsTitle);
					result.Add("NewsContent", news.NewsContent);
					result.Add("PublishMan", news.PublishMan);
					result.Add("CreateTime", news.CreateTime.ToString("yyyy-MM-dd"));
					result.Add("NewsType", GetTypeNameByValue(news.NewsTypeId));
					ContentDetail = result;
				}
				else
				{
					//页面不存在
				}
				return result;
			}
		}

		protected string NewsID
		{
			get
			{
				return base.Request["newsId"];
			}
		}

		protected string GetTypeNameByValue(int parentId)
		{
			DTVType type = DTVBusiness.TypeManager.GetTypeById(parentId);
			if (type != null)
			{
				return type.TypeName;
			}
			return string.Empty;
		}

		protected Dictionary<string, string> ContentDetail
		{
			get
			{
				return (this.ViewState["contentDetail"] as Dictionary<string, string>);
			}
			set
			{
				this.ViewState["contentDetail"] = value;
			}
		}
	}
}